<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<style type="text/css">
/*    .datagrid-cell img{
        width: 60px;
        height: 60px;
    }*/
</style>
<div id="main_depart_list" class="easyui-layout" fit="true">
    <div region="center" style="padding: 1px;">
        <t:datagrid name="columnsList" title=""
                    actionUrl="columnsController.do?columnsgrid"
                    treegrid="true" idField="id" pagination="false" >
                    <%--treegrid="true" idField="id" pagination="false" onLoadSuccess="bandImg">--%>
            <t:dgCol title="common.id" field="columnsId" treefield="id" hidden="true" ></t:dgCol>
            <t:dgCol title="层级关系" field="hierarchical" treefield="fieldMap.hierarchical" hidden="true" width="100"></t:dgCol>
            <t:dgCol title="标题" field="title" treefield="text" width="100"></t:dgCol>
            <t:dgCol title="是否引导偏好" field="guidePrefer" treefield="fieldMap.guidePrefer" dictionary="isno" width="100"></t:dgCol>
            <t:dgCol title="是否默认" field="isDef" treefield="fieldMap.isDef" dictionary="isno" width="100"></t:dgCol>
            <t:dgCol title="是否有效" field="enable"  treefield="src" dictionary="isno" width="100"></t:dgCol>
            <t:dgCol title="排序" field="sort"  treefield="fieldMap.sort" width="100" ></t:dgCol>
            <t:dgCol title="简介" field="intro"  treefield="fieldMap.intro" width="200" ></t:dgCol>
            <t:dgCol title="common.operation" field="opt" width="100"></t:dgCol>
            <t:dgDelOpt operationCode="deleteColumns" url="columnsController.do?delGoodsCategory&columnsId={id}" title="common.delete"></t:dgDelOpt>
            <t:dgConfOpt operationCode="startColumns" url="columnsController.do?enableGoodsCategory&columnsId={id}" title="启用" message="是否设为有效？" exp="src#eq#0"></t:dgConfOpt>
            <t:dgConfOpt operationCode="stopColumns" url="columnsController.do?enableGoodsCategory&columnsId={id}" title="禁用" message="是否设为无效？" exp="src#eq#1"></t:dgConfOpt>
            <t:dgToolBar title="添加分类"  operationCode="addColumns" icon="icon-add" width="600" height="300" funname="addOrg"></t:dgToolBar>
            <t:dgToolBar title="修改分类"  operationCode="editColumns" icon="icon-edit" url="columnsController.do?addorupdate" width="600" height="300" funname="f_update"></t:dgToolBar>
        </t:datagrid>
    </div>
</div>


<script type="text/javascript">
    $(function() {
        var li_east = 0;
    });
    function dictionarys(val){
        if(val==0){
            return "否";
        }
        if(val==1){
            return "是";
        }
    }

    function addOrg() {
        var id = "";
        var rowsData = $('#columnsList').datagrid('getSelections');
        if (rowsData.length == 1) {
            id = rowsData[0].id;
        }
        var url = "columnsController.do?addorupdate&pid="+id;
        add('添加分类', url, "columnsList",680,400);
    }
    function f_update() {

        var rowsData = $('#columnsList').datagrid('getSelections');
        if (!rowsData || rowsData.length==0) {
            tip('请选择编辑项目');
            return;
        }
        if (rowsData.length>1) {
            tip('请选择一条记录再编辑');
            return;
        }

        var url = "columnsController.do?addorupdate&columnsId=" + rowsData[0].id;
        add('修改分类', url, "columnsList",680,400);
    }

</script>